const Page = {
	map: null,
	hashCode(str) {
		let hash = 0;
		for (let i = 0; i < str.length; i++) {
			var character = str.charCodeAt(i);
			hash = ((hash << 5) - hash) + character;
			hash = hash & hash;
		}
		return hash;
	},
	getInfo() {
		if (!this.map) {
			this.map = window.localStorage.pageMap ? JSON.parse(window.localStorage.pageMap) : {};
		}
		return this.map;
	},
	get() {
		return this.getInfo()[this.hashCode(window.location.pathname)];
	},
	set(value) {
		this.getInfo()[this.hashCode(window.location.pathname)] = this.hashCode(value);
		window.localStorage.pageMap = JSON.stringify(this.getInfo());
	}
};

export default Page;